﻿using System.Text;

namespace ArtheaEngine
{
    public partial class Player
    {
        [Flag] public const long AutoTick = (1L << 1);
        [Flag] public const long Color = (1L << 0);

        private ClassType _class;
        public IConnection Connection { get; set; }

        public ClassType Class
        {
            get { return _class; }
            set
            {
                _class = value;
                if (value != null)
                    _ClassID = value.Name;
            }
        }

        partial void OnLoaded()
        {
            _class = World.Classes.FindByName(ClassId);
        }

        partial void OnClassIdChanged()
        {
            _class = World.Classes.FindByName(ClassId);
        }

        public override void Dispose()
        {
            base.Dispose();
            Connection = null;
        }

        public override void WriteLine()
        {
            Connection.WriteLine();
        }

        public override void WriteLine(object obj)
        {
            Connection.WriteLine(obj);
        }

        public override void WriteLine(string value)
        {
            Connection.WriteLine(value);
        }

        public override void WriteLine(string format, params object[] args)
        {
            Connection.WriteLine(format, args);
        }

        public override void Write(string value)
        {
            Connection.Write(value);
        }

        public override void Write(string format, params object[] args)
        {
            Connection.Write(format, args);
        }

        public override void Write(byte[] value)
        {
            Connection.Write(value);
        }

        public override void Write(object obj)
        {
            Connection.Write(obj);
        }

        public override void Page(StringBuilder buf)
        {
            Connection.Page(buf);
        }
    }


    partial class PlayerObject
    {
        public PlayerObject(Player ch, Object obj, WearLocation loc)
        {
            Player = ch;
            Object = obj;
            WearLocation = loc;
        }
    }

}